package com.cuit.xsc.weishare;



import java.io.File;

import android.app.Application;
import android.content.Intent;

import com.cuit.xsc.weishare.logic.MainService;
import com.cuit.xsc.weishare.util.FileUtil;
import com.cuit.xsc.weishare.util.ImageCache;
import com.cuit.xsc.weishare.util.ImageCacheList;
import com.cuit.xsc.weishare.util.LogUtil;

public class WeiShareApplication extends Application
{
	private static WeiShareApplication instance;
	//private UserInfo currentUser;
	
	/**
	 * Image cache, one for all activities and orientations
	 */
	private ImageCache mImageCache;
	private ImageCacheList mImageCacheList;
	/**
	 * Web request cache, one for all activities and orientations
	 */
	//private RequestCache mRequestCache;

	public WeiShareApplication()
	{
		instance = this;
	}
	
	public static WeiShareApplication getInstance()
	{
		return instance;
	}
	
	@Override
	public void onCreate()
	{
		setCachePath();
		LogUtil.d(this, "application start");
		mImageCache = new ImageCache();
		mImageCacheList = new ImageCacheList();
		//start main service
		Intent service=new Intent(this, MainService.class);
	    startService(service);
	}
	
	public void setCachePath()
	{
		 File f = new File(FileUtil.imgFilePath);
    	 if(!f.exists())
            {
            	f.mkdirs();
            }
	}
	
	
	public ImageCache getImageCache() {
		return mImageCache;
	}
	
	public ImageCacheList getImageCacheList() {
		return mImageCacheList;
	}


}
